/*
 * 登录相关函数和 axios 封装
 *
 */

import axios from "axios";
import { adornUrl, adornData } from "./index.js";

let http = axios.create({
  timeout: 1000 * 30,
  withCredentials: true,
  headers: {
    "Content-Type": "application/json; charset=utf-8",
    "Access-Control-Allow-Origin": "*"
  }
});

http.adornUrl = adornUrl;

http.adornData = adornData;

const getUUID = function() {
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => {
    return (c === "x" ? (Math.random() * 16) | 0 : "r&0x3" | "0x8").toString(
      16
    );
  });
};

export { http, getUUID };
